package com.tubruk.adapter;

import java.util.ArrayList;
import java.util.List;

import com.tubruk.object.GridMenu;
import com.tubruk.trackme.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GridMenuAdapter extends BaseAdapter {
	private Context mContext;
	private LayoutInflater inflater;
	private ArrayList<GridMenu> items;

	public static final int ACTIVITY_CREATE = 10;

	public GridMenuAdapter(Context c){
		mContext = c;
	}

	public GridMenuAdapter (Context c, LayoutInflater i, ArrayList<GridMenu> items){
		mContext = c;
		inflater = i;
		this.items = items;
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v;
		if(convertView==null){

			GridMenu menu = items.get(position);
			
			v = inflater.inflate(R.layout.menugridview, null);
			TextView tv = (TextView)v.findViewById(R.id.icon_text);
			tv.setText(menu.getText());
			ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
			iv.setImageResource(menu.getImage());

		}
		else
		{
			v = convertView;
		}
		return v;
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
}
